#include "stdafx.h"
#include "sceneBirthPosMgr_t.h"
#include <WinSock2.h>

void sceneBirthPosMgr_t::init( const string & config )
{
	TiXmlDocument xml;
	if ( !xml.LoadFile(config.c_str()) )
	{
		return;
	}

	TiXmlElement* root = xml.RootElement();
	TiXmlElement* elem = root->FirstChildElement();

	TiXmlElement* scene = elem->FirstChildElement();

	TiXmlElement* birthPos=NULL;
	bool isFristScene = true;
	for ( birthPos=scene->FirstChildElement(); birthPos; birthPos=birthPos->NextSiblingElement() )
	{
		string sceneid = birthPos->Attribute("sceneid");
		string xpos = birthPos->Attribute("xpos");
		string ypos = birthPos->Attribute("ypos");

		sceneBirthInfo.insert(make_pair(StringAsInt(sceneid), pos(StringAsInt(xpos),StringAsInt(ypos))));
	}
}


bool sceneBirthPosMgr_t::getSwitchInfo( int srcScene, int srcX, int srcY, int & destScene, int & destX, int destY )
{
	return true;
}


bool sceneBirthPosMgr_t::getBirthPos( int scene, int & x, int & y )
{
	sceneBirthPosMap::iterator iter;
	iter = sceneBirthInfo.find(scene);
	if (iter==sceneBirthInfo.end()) return false;
	x = iter->second.x;
	y = iter->second.y;
	return true;
}